# CAS-EBX-03: Projektarbeit Valentina Vuksic, Beat Liechti
# Project	: k2k - Kaffee2000
# Version	: 1.0
# Date		: 2010-04-06
# Author	: Valentina Vuksic (VUKSV1), Beat Liechti (LIECB2)
#
# Last Modifications: V1.0, VUKSV1/LIECB2, 2010-04-06
# Initial release

# Include enviroments variable for the target
include makevars_arm
#include makevars_x86

# Tool names
CROSS_COMPILE	= ${TARGET}-
AS		= $(CROSS_COMPILE)as
AR 		= $(CROSS_COMPILE)ar
CC 		= $(CROSS_COMPILE)gcc
CPP 		= $(CC) -E
LD 		= $(CROSS_COMPILE)ld
NM 		= $(CROSS_COMPILE)nm
OBJCOPY 	= $(CROSS_COMPILE)objcopy
OBJDUMP 	= $(CROSS_COMPILE)objdump
RANLIB 		= $(CROSS_COMPILE)ranlib
READELF 	= $(CROSS_COMPILE)readelf
SIZE 		= $(CROSS_COMPILE)size
STRINGS 	= $(CROSS_COMPILE)strings
STRIP 		= $(CROSS_COMPILE)strip
export	AS AR CC CPP LD NM OBJCOPY OBJDUMP RANLIB READELF SIZE STRINGS STRIP

# Build settings
CFLAGS		= $(EXTRACFLAGS) -O2 -gdwarf-2 -Wall
HEADER_OPS	= -I${MICROWIN_HEADER}
LDFLAGS 	= -lrt -lnano-X -lpng -lfreetype -ljpeg -lz $(EXTRALIBS) -L${MICROWIN_LIB} -L${FREETYPE_LIB} -Wl,-Map=k2k_main.map

# Installation variables
EXEC_NAME	= k2kaffee
INSTALL		= install

# Files needed for the build
OBJS = k2k_main.o k2k_IO.o k2k_X86IO.o k2k_StateHandlerData.o k2k_StateMachineTypes.o k2k_StateMachine.o k2k_StateHandlerOff.o k2k_StateHandlerRdy1.o k2k_StateHandlerRdy2.o k2k_StateHandlerRstr.o k2k_StateHandlerEspr.o k2k_StateHandlerMlkC.o k2k_StateHandlerCln.o k2k_AudioPlayer.o k2k_NanoX.o k2k_Signal.o
# Make rules
all: k2kaffee

.c.o:
		$(CC) $(CFLAGS) $(HEADER_OPS) -c $<

k2kaffee: 	${OBJS}
		$(CC) -o $(EXEC_NAME) ${OBJS} $(LDFLAGS)

install:	k2kaffee
		test -d $(INSTALL_DIR) || $(INSTALL) -d -m 755 $(INSTALL_DIR)
		$(INSTALL) -m 755 $(EXEC_NAME) $(INSTALL_DIR)
		cp -fr $(SOUNDS_DIR) $(INSTALL_SOUND_DIR)

doc:
		doxygen

clean:
		rm -f *.o $(EXEC_NAME)
		rm -fdr doc
		rm -fdr $(INSTALL_DIR)/$(SOUNDS_DIR)
		
distclean:
		rm -f *~
		rm -f *.map
		rm -f *.o $(EXEC_NAME) 
		rm -r doc
		rm -dr $(INSTALL_DIR)/$(SOUNDS_DIR)

